import requests
class IHRMEmpManageApi:
    # 添加员工
    @classmethod
    def add_emp_api(cls,token,add_emp_body):
        add_emp_url = "http://ihrm2-test.itheima.net/api/sys/user"
        add_emp_header = {"Content-Type": "application/json", "Authorization":token}
        resp =requests.post(url=add_emp_url,headers=add_emp_header,json=add_emp_body)
        return resp
    # 查询员工
    @classmethod
    def query_emp_api(cls,emp_id,token):
        select_emp_url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        select_emp_Head = {"Authorization": token}
        select_resp = requests.get(url=select_emp_url, headers=select_emp_Head)
        return select_resp
    # 修改员工
    @classmethod
    def modify_emp_api(cls,emp_id,token,modify_emp_body):
        modify_emp_url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        modify_emp_Header = {"Content-Type": "application/json",
                             "Authorization": token}
        modify_resp = requests.put(url=modify_emp_url, headers=modify_emp_Header, json=modify_emp_body)
        return modify_resp
    # 删除员工
    @classmethod
    def delete_emp_api(cls,emp_id,token):
        delete_emp_url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        delete_emp_Header = {"Authorization": token}
        delete_resp = requests.delete(url=delete_emp_url, headers=delete_emp_Header)
        return delete_resp
